(prefix-width (if (eq which-key-show-prefix 'left) prefix-len 0))
(avl-width (when (cdr max-dims) (- (cdr max-dims) prefix-width)))
(keys-rem formatted-keys)
- (max-iter (+ 1 n-keys))
- (iter-n 0)
- keys-per-page pages first-page first-page-str page-res)
- (while (and (<= iter-n max-iter) keys-rem)
- (setq iter-n (1+ iter-n)
- page-res (which-key/create-page vertical max-height avl-width prefix-width keys-rem)
- (max-pages (+ 1 (length keys-rem)))
++ (max-pages (+ 1 (length formatted-keys)))
+ (page-n 0)
+ keys-per-page pages first-page first-page-str page-res no-room
+ max-pages-reached)
+ (while (and keys-rem (not max-pages-reached) (not no-room))
+ (setq page-n (1+ page-n)
+ page-res (which-key/create-page keys-rem
+ max-lines avl-width prefix-width
+ vertical which-key-show-page-number page-n)
pages (push page-res pages)
keys-per-page (push (if (nth 4 page-res) (nth 4 page-res) 0) keys-per-page)
- keys-rem (nth 3 page-res)))
+ keys-rem (nth 3 page-res)
+ no-room (<= (car keys-per-page) 0)
+ max-pages-reached (>= page-n max-pages)))
;; not doing anything with other pages for now
(setq keys-per-page (reverse keys-per-page)
pages (reverse pages)
first-page (car pages)
first-page-str (concat prefix-string (car first-page)))
- (if (or (<= n-keys 0) (<= (car keys-per-page) 0))
- (progn
- (message "which-key can't show keys: The settings and/or frame size are too restrictive.")
- (cons 0 0))
- ;; (when (> (length pages) 1) (setq first-page (concat first-page "...")))
- (if (eq which-key-popup-type 'minibuffer)
- (let (message-log-max) (message "%s" first-page-str))
- (with-current-buffer which-key--buffer
- (erase-buffer)
- (insert first-page-str)
- (goto-char (point-min))))
- (cons (nth 1 first-page) (nth 2 first-page)))))
+ (cond (no-room
+ (message "which-key can't show keys: The settings and/or frame size are too restrictive.")
+ (cons 0 0))
+ (max-pages-reached
+ (error "error: which-key reached the maximum number of pages")
+ (cons 0 0))
+ ((<= (length formatted-keys) 0)
- (error "error: which-key: no keys to display")
++ (message "which-key: no keys to display")
+ (cons 0 0))
+ (t
+ (if (eq which-key-popup-type 'minibuffer)
+ (let (message-log-max) (message "%s" first-page-str))
+ (with-current-buffer which-key--buffer
+ (erase-buffer)
+ (insert first-page-str)
+ (goto-char (point-min))))
+ (cons (nth 1 first-page) (nth 2 first-page))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Update